package com.hsc.yalebao.tools;

import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.net.Uri;
import android.os.Build.VERSION;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.secret.AESHelper;
import com.hsc.yalebao.secret.DES;
import com.hsc.yalebao.secret.SecretUtil;
import com.hsc.yalebao.weight.LogUtils;
import java.io.File;

public class SystemHelper
{
  private static final String TAG = SystemHelper.class.getSimpleName();

  public static void createShortcut(Context paramContext, Class<?> paramClass)
  {
    Intent localIntent1 = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
    localIntent1.putExtra("android.intent.extra.shortcut.NAME", paramContext.getString(2131296415));
    localIntent1.putExtra("duplicate", false);
    Intent localIntent2 = new Intent(paramContext, paramClass);
    localIntent2.setAction("android.intent.action.MAIN");
    localIntent2.addCategory("android.intent.category.LAUNCHER");
    localIntent1.putExtra("android.intent.extra.shortcut.INTENT", localIntent2);
    localIntent1.putExtra("android.intent.extra.shortcut.ICON_RESOURCE", Intent.ShortcutIconResource.fromContext(paramContext, 2130837618));
    paramContext.sendBroadcast(localIntent1);
  }

  public static int getAppVersionCode(Context paramContext)
  {
    try
    {
      int i = paramContext.getPackageManager().getPackageInfo(paramContext.getPackageName(), 0).versionCode;
      return i;
    }
    catch (Exception localException)
    {
      LogUtils.e(TAG, localException.getMessage());
    }
    return -1;
  }

  public static String getAppVersionName(Context paramContext)
  {
    try
    {
      String str = paramContext.getPackageManager().getPackageInfo(paramContext.getPackageName(), 0).versionName;
      return str;
    }
    catch (Exception localException)
    {
      LogUtils.e(TAG, localException.getMessage());
    }
    return "";
  }

  public static String getMobileNumber(Context paramContext)
  {
    return ((TelephonyManager)paramContext.getSystemService("phone")).getLine1Number();
  }

  public static int getNetworkType(Context paramContext)
  {
    if (paramContext != null)
      try
      {
        ConnectivityManager localConnectivityManager = (ConnectivityManager)paramContext.getSystemService("connectivity");
        if (localConnectivityManager != null)
        {
          NetworkInfo.State localState1 = localConnectivityManager.getNetworkInfo(1).getState();
          if (NetworkInfo.State.CONNECTED == localState1)
            return 1;
          NetworkInfo.State localState2 = localConnectivityManager.getNetworkInfo(0).getState();
          NetworkInfo.State localState3 = NetworkInfo.State.CONNECTED;
          if (localState3 == localState2)
            return 0;
        }
      }
      catch (Exception localException)
      {
        LogUtils.e(TAG, localException.getMessage());
      }
    return -1;
  }

  public static DisplayMetrics getScreenInfo(Context paramContext)
  {
    WindowManager localWindowManager = (WindowManager)paramContext.getSystemService("window");
    DisplayMetrics localDisplayMetrics = new DisplayMetrics();
    localWindowManager.getDefaultDisplay().getMetrics(localDisplayMetrics);
    return localDisplayMetrics;
  }

  public static String getServer(Context paramContext)
  {
    String str1 = SecretUtil.jiemi1(SecretUtil.decrypt(SecretUtil.decrypt2(SecretUtil.getEnString(paramContext, 2131034113))), 7);
    Object localObject = "";
    try
    {
      String str3 = DES.decryptDES(str1, "*jDD46@$");
      localObject = str3;
      String[] arrayOfString = AESHelper.decrypt((String)localObject, "aqwer!&%").split(",");
      String str2 = arrayOfString[new java.util.Random().nextInt(arrayOfString.length)];
      if ((str2 == null) || (str2.equals("")))
        str2 = "1.1.1.1";
      AppConstants.IP = str2;
      AppConstants.BASEIP = AppConstants.BASEXIEYI + str2;
      AppConstants.BASE_URL = AppConstants.BASEIP + ":" + AppConstants.BASEPORT + "/Api";
      AppConstants.IMIP = str2;
      AppConstants.BASE_URL_IMG = AppConstants.BASEIP + AppConstants.BASEPORT_IMG;
      return AppConstants.IP;
    }
    catch (Exception localException)
    {
      while (true)
        localException.printStackTrace();
    }
  }

  public static boolean hasShortCut(Context paramContext)
  {
    if (Build.VERSION.SDK_INT < 8);
    for (String str = "content://com.android.launcher.settings/favorites?notify=true"; ; str = "content://com.android.launcher2.settings/favorites?notify=true")
    {
      ContentResolver localContentResolver = paramContext.getContentResolver();
      Uri localUri = Uri.parse(str);
      String[] arrayOfString = new String[1];
      arrayOfString[0] = paramContext.getString(2131296415);
      Cursor localCursor = localContentResolver.query(localUri, null, "title=?", arrayOfString, null);
      if ((localCursor == null) || (!localCursor.moveToFirst()))
        break;
      localCursor.close();
      return true;
    }
    return false;
  }

  public static void installAPK(Context paramContext, String paramString)
  {
    Intent localIntent = new Intent("android.intent.action.VIEW");
    localIntent.setDataAndType(Uri.fromFile(new File(paramString)), "application/vnd.android.package-archive");
    paramContext.startActivity(localIntent);
  }

  public static boolean isConnected(Context paramContext)
  {
    try
    {
      ConnectivityManager localConnectivityManager = (ConnectivityManager)paramContext.getSystemService("connectivity");
      boolean bool1 = false;
      if (localConnectivityManager != null)
      {
        NetworkInfo localNetworkInfo = localConnectivityManager.getActiveNetworkInfo();
        bool1 = false;
        if (localNetworkInfo != null)
        {
          boolean bool2 = localNetworkInfo.isAvailable();
          bool1 = false;
          if (bool2)
            bool1 = true;
        }
      }
      return bool1;
    }
    catch (Exception localException)
    {
      LogUtils.e(TAG, localException.getMessage());
    }
    return false;
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tools.SystemHelper
 * JD-Core Version:    0.6.2
 */